/*
 * @(#)XfdmDecisionTreeNode.java        1.0 2000/05/09
 *
 * This file is part of Xfuzzy 3.0, a design environment for fuzzy logic
 * based systems.
 *
 * (c) 2000 IMSE-CNM. The authors may be contacted by the email address:
 *                    xfuzzy-team@imse.cnm.es
 *
 * Xfuzzy is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * Xfuzzy is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */


package xfuzzy.xfdm.model.algorithm;

import xfuzzy.lang.*;

/**
 * Clase que describe un nodo de un �rbol de decisi�n difuso
 * 
 * @author Francisco Jos� Moreno Velo
 *
 */
public class XfdmDecisionTreeNode {

	//----------------------------------------------------------------------------//
	//                           CONSTANTES P�BLICAS                              //
	//----------------------------------------------------------------------------//

	/**
	 * C�digo para representar un nodo interno
	 */
	public static final int INNER = 1;
	
	/**
	 * C�digo para representar un nodo hoja
	 */
	public static final int LEAF = 2;
	
	//----------------------------------------------------------------------------//
	//                            MIEMBROS PRIVADOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * Tipo de nodo (INNER o LEAF)
	 */
	private int kind;
	
	/**
	 * Atributo al que se refiere el nodo. Si es interno es un atributo de entrada.
	 * Si es hoja se refiere al atributo de salida.
	 */
	private Type attrib;
	
	/**
	 * Ramas de un nodo interno. El �ndice de la rama corresponde con el �ndice de la
	 * MF al atributo del nodo
	 */
	private XfdmDecisionTreeNode[] branch;
	
	/**
	 * �ndice de la MF que representa la clase en un nodo hoja
	 */
	private int classifMF;

	//----------------------------------------------------------------------------//
	//                                CONSTRUCTOR                                 //
	//----------------------------------------------------------------------------//

	/**
	 * Constructor para un nodo interno
	 */
	public XfdmDecisionTreeNode(Type attrib, XfdmDecisionTreeNode[] branch) {
		this.kind = INNER;
		this.attrib = attrib;
		this.branch = branch;
		this.classifMF = -1;
	}
	
	/**
	 * Constructor para un nodo hoja
	 * @param attrib
	 * @param classifMF
	 */
	public XfdmDecisionTreeNode(Type attrib, int classifMF) {
		this.kind = LEAF;
		this.attrib = attrib;
		this.classifMF = classifMF;
		this.branch = null;
	}
	
	//----------------------------------------------------------------------------//
	//                             M�TODOS P�BLICOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * Obtiene el tipo de nodo
	 */
	public int getKind() {
		return this.kind;
	}
	
	/**
	 * Obtiene el atributo del nodo
	 */
	public Type getAttrib() {
		return this.attrib;
	}
	
	/**
	 * Obtiene el �ndice de la MF de un nodo hoja
	 */
	public int getClassifMF() {
		return this.classifMF;
	}
	
	/**
	 * Obtiene las ramas de un nodo interno
	 * @return
	 */
	public XfdmDecisionTreeNode[] getBranches() {
		return this.branch;
	}
}